//创建点赞表
const db = uniCloud.database()
const cmd = db.command
module.exports = {
	_before: function() { // 通用预处理器

	},
	//id文章id,islikearr用户数组,islike喜欢或者不喜欢,islike ture or flase
	//tyep类型点赞0，不喜欢1
	async createlike(id, islikearr,type=0) {
		let obj = {}
		obj['video-id'] = id
		if (type==0) {
			//喜欢点赞
			obj['userlike_arr'] = islikearr
			obj['userdislike_arr']=[]
		} else {
			//不喜欢
			obj['userdislike_arr'] = islikearr
			obj['userlike_arr'] =[]
		}
		await db.collection('like').add({
			...obj
		})

		//'user_id':db.getCloudEnv('$cloudEnv_uid')

	}
}